﻿Imports System.Data.OleDb

Public Class frmRankingVtaPosvta

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim limpiarTemporalRanking As New VtaPosvta_querys
        limpiarTemporalRanking.eliminarTemporalesRankingVtaPosvta()
        Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim Da As New OleDbDataAdapter
        Dim Cmd As New OleDbCommand
        Dim Dt As DataTable

        'DataGridView1.Visible = True
        'crvReportes.Visible = True

        With Cmd
            .CommandType = CommandType.Text

            .CommandText = "SELECT  noap_ado, AVG(promedio_ado) AS promedio_ado FROM temporal_rankingvtaposvta GROUP BY temporal_rankingvtaposvta.noap_ado order by AVG(promedio_ado)DESC"
            .Connection = cadenaConexBD()
        End With

        Da.SelectCommand = Cmd
        Dt = New DataTable
        Da.Fill(Dt)
        DataGridView1.DataSource = Dt

        Dim rpt As New rptRankingVtaPosvta
        rpt.SetDataSource(Dt)
        crvReportes.ReportSource = rpt
        crvReportes.Visible = True

        Show()
    End Sub

    Private Sub frmRankingVtaPosvta_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DataGridView1.DataSource = Nothing
        crvReportes.Visible = False
    End Sub
End Class